package org.jeecg.common.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.jeecg.common.entity.Room;

import java.util.List;


/**
 * @Description:
 * @Author: 国子软件
 * @Date:   2022-04-28
 * @Version: V1.0
 */
@Mapper
public interface RoomMapper extends BaseMapper<Room> {


    @Select("SELECT " +
            "r.*, " +
            "SUM(p.standard_area) as used_area, " +
            "GROUP_CONCAT(p.name) as users " +  // 添加这一行来聚合人员名称
            "FROM hs_basics_room r " +
            "LEFT JOIN hs_person p ON CAST(r.id AS CHAR) = p.baseinfo_room_id " +
            "WHERE r.basics_floor_id = #{floorId} " +
            "GROUP BY r.id")
    List<Room> queryListWithUsedAreaByFloorId(@Param("floorId") String floorId);

}
